package com.srcbox.file.ui

import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.srcbox.file.R
import kotlinx.android.synthetic.main.welcome.*
import java.util.*

class Welcome : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.welcome)
//        GlobalMethods(this).initActivityUi()


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.decorView.systemUiVisibility =
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.statusBarColor = Color.TRANSPARENT;
        }
        welcomeImg.setImageBitmap(BitmapFactory.decodeStream(assets.open("img/b.png")))

        val timer = Timer()
        timer.schedule(object : TimerTask() {
            override fun run() {
                val intent = Intent(this@Welcome, Main::class.java)
                startActivity(intent)
                finish()
            }

        }, 800)

    }
}


/*
val linearLayout = LinearLayout(this)
val layoutParams = WindowManager.LayoutParams()
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT
linearLayout.layoutParams = layoutParams
linearLayout.orientation = LinearLayout.VERTICAL
linearLayout.gravity = Gravity.CENTER
linearLayout.setBackgroundColor(Color.parseColor("#ffffff"))

EggUtil.alterStateBarColor(this, AppSetting.BACKGROUND_COLOR)

val lottie = LottieAnimationView(this)
lottie.setLayerType(View.LAYER_TYPE_HARDWARE, null)
val lottieCompositionFactory = LottieCompositionFactory.fromAsset(this, "anim/back.json")
lottieCompositionFactory.addListener {
    lottie.setComposition(it)
    lottie.speed = 1.1f
    lottie.playAnimation()
}

lottie.addAnimatorListener(object : Animator.AnimatorListener {
    override fun onAnimationRepeat(animation: Animator?) {}

    override fun onAnimationEnd(animation: Animator?) {
        lottie.setLayerType(View.LAYER_TYPE_NONE, null)
        val intent = Intent(this@Welcome, Main::class.java)
        startActivity(intent)
        finish()
    }

    override fun onAnimationCancel(animation: Animator?) {}

    override fun onAnimationStart(animation: Animator?) {}
})

linearLayout.addView(lottie)
EggUtil.statusBarLightMode(this)
*/